import random
from selenium import webdriver

##此项目我们使用Chrome浏览器做访问
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument('--headless')
chromeOptions.add_argument('--disable-gpu')

# Chorm浏览器的User-Agent代理，可以自己添加不同版本的Chorm代理，模拟不用的用户请求，在这里只放一个User-Agent
userAgentlist = [
    "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36"
]
url = 'http://basic.10jqka.com.cn/300001/equity.html'

def get_random_header():  # 随机获取请求头
    headers = {'User-Agent': random.choice(userAgentlist),
               'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
               'Accept-Encoding': 'gzip, deflate, br'}
    return headers